/**
 * List of [tblName] [tblTitle] .
 * Created by buzhizhe CodeConvert on 2021/6/9 11:58:29.
 */

$(function () {
    initPage();
    loadData();
});

//初始化页面元素
function initPage() {
    VM = new Vue({
        delimiters: ["[[", "]]"],
        el: '#app',
        data: {
            formdata: {
            },
            result: {}
        }
    });

}

//加载数据
function loadData() {
    var id = GetQueryString("id");
    var url = ApiHost + "/[subFolder]/[tblName]view";
    ajax(url, { id: id }, function (result) {
        var code = result.statecode;
        if (code == 0) {
            VM.formdata = result.data;
            dealData();
        } else {
            layerAlert("获取失败：" + result.message);
        }
    });

}

//处理数据
function dealData() {
    //console.log("model data:",VM.formData);
}

//保存数据
function formSubmit() {
    
    var url = ApiHost + "/[subFolder]/[tblName]edit";
    var post_data = $('#formedit').serialize();
    ajax(url, post_data, function (result) {
        var code = result.statecode;
        if (code == 0) {
            layerAlert("提交成功");
        } else if (code == 1001) {
            layerMsg("验证失败：" + result.message);
        } else {
            layerAlert("提交失败：" + result.message);
        }
    });

}



